//
//  YangYao.m
//  AnimationDemo
//
//  Created by zhangjikuan on 2020/6/1.
//  Copyright © 2020 hsgd. All rights reserved.
//

#import "YangYao.h"

@implementation YangYao
- (CALayer *)yaoLayer {
    /// 平均分为三分
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0,0)];
    [path addLineToPoint:CGPointMake(30,0)];
    
    CAShapeLayer *layer = [CAShapeLayer layer];
//    layer.frame = CGRectMake(15, 15, 30, 5);
    
    layer.path = path.CGPath;
    layer.fillColor = [UIColor blueColor].CGColor;
    layer.lineWidth = 5;
    
    layer.borderWidth = 0.1;
    
    layer.strokeEnd = 1.0;
    layer.strokeColor = UIColor.whiteColor.CGColor;
    layer.strokeStart = 0.0;
    
    CABasicAnimation *pathAnima = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
    pathAnima.duration = 1.5f;
    pathAnima.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    pathAnima.fromValue = [NSNumber numberWithFloat:0.0f];
    pathAnima.toValue = [NSNumber numberWithFloat:1.0];
    pathAnima.fillMode = kCAFillModeForwards;
    pathAnima.removedOnCompletion = NO;
    [layer addAnimation:pathAnima forKey:@"strokeEndAnimation"];
    
    
    return layer;
}
@end
